import datetime
from google.appengine.ext import db
from google.appengine.api import users

class Problem(db.Model):
    level = db.IntegerProperty()
    user = db.UserProperty()
    title = db.StringProperty()
    start_date = db.DateProperty()
    codebody = db.TextProperty()
    variables = db.TextProperty()
    solution = db.StringProperty()
    solved = db.BooleanProperty()
    
    def get_vars(self):
        vardict = {}
        for var in self.variables.split("\r\n"):
            v = var.split(":")
            vardict[v[0]] = eval(v[1])()
        return vardict
    vardict = property(get_vars)
        

class User(db.Model):
    user = db.UserProperty()
    level = db.IntegerProperty()
    
    
